<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var num = prompt('输入一个数字，判断这个数字是否是质数');
    var a = 0;
    for (var i=1; i<=num; i++) {
      if (num%i==0) {
        ++a;
      }
    }
    if (a>2 || a==1) {
      alert(num + '不是质数。');
    } else {
      alert(num + '是质数。');
    }
  </script>
</body>
</html>